procedure searchSubMatrix(); // Matrix A[na][ma], Matrix B[nb][mb] 

var
	i, j, n, m, nn, mm : longint;
	hh : int64;
	h, ha, hb : array[-10..110, -10..110] of int64;     
	dx, dy : array[0..110] of int64;

	function getHB(si, sj, ei, ej : longint) : int64;
	begin
		result := hb[ei][ej] - hb[ei][sj] * dx[ej - sj] - hb[si][ej] * dy[ei - si] + hb[si][sj] * dx[ej - sj] * dy[ei - si];
	end; 

	function getHA(si, sj, ei, ej : longint) : int64;
	begin
		result := ha[ei][ej] - ha[ei][sj] * dx[ej - sj] - ha[si][ej] * dy[ei - si] + ha[si][sj] * dx[ej - sj] * dy[ei - si];
	end;   

	procedure hash();

	var
		i, j, nn, mm : longint;
		v : array[0..110, 0..110] of int64;

	begin
		fillchar(v, sizeof(v), 0);
		nn := n + 1;
		mm := m + 1;
		for i := 1 to nn do
			for j := 1 to mm do
				v[i][j] := v[i][j - 1] * 29 + a[i][j - 1];
		fillchar(h, sizeof(h), 0);
		for i := 1 to nn do
			for j := 1 to mm do
				h[i][j] := h[i - 1][j] * 31 + v[i - 1][j];	
	end;	

begin
	n := na;
	m := ma;
	hash();
	ha := h;
	a := b; 
	n := nb;
	m := mb;
	hash();
	hb := h;
	dx[0] := 1;
	dy[0] := 1;
	for i := 1 to 105 do begin
		dx[i] := dx[i - 1] * 29;
		dy[i] := dy[i - 1] * 31;
	end;
	hh := getHB(1, 1, nb + 1, mb + 1);
	nn := na - nb + 1;
	mm := ma - mb + 1;
	for i := 1 to nn do
		for j := 1 to mm do 
			if hh = getHA(i, j, i + nb, j + mb) then begin
					writeln(i, ' ', j);
			end; 
end;